package com.hua.ui;

import javax.swing.*;
import javax.swing.border.EmptyBorder;

import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class UploadProgressWindow extends JFrame {
    private JProgressBar progressBar=new JProgressBar();

    public UploadProgressWindow(String name,String path,String size) {
    	JFrame frame = new JFrame("文件上传下载");
    	
    	setAlwaysOnTop(true);
    	setTitle("文件传输");
    	
    	getContentPane().setLayout(null);
    	
    	JLabel lblNewLabel = new JLabel(name);
    	lblNewLabel.setFont(new Font("Alimama ShuHeiTi", Font.PLAIN, 15));
    	lblNewLabel.setBounds(14, 13, 400, 26);
    	getContentPane().add(lblNewLabel);
    	
    	JLabel lblNewLabel_1 = new JLabel("路径:"+path);
    	lblNewLabel_1.setFont(new Font("Alimama ShuHeiTi", Font.PLAIN, 15));
    	lblNewLabel_1.setBounds(14, 41, 400, 26);
    	getContentPane().add(lblNewLabel_1);
    	
    	progressBar.setBounds(14, 101, 467, 35);
    	progressBar.setStringPainted(true);
    	getContentPane().add(progressBar);
    	
    	JLabel lblNewLabel_1_1 = new JLabel("大小:"+size+"MB");
    	lblNewLabel_1_1.setFont(new Font("Alimama ShuHeiTi", Font.PLAIN, 15));
    	lblNewLabel_1_1.setBounds(14, 69, 140, 26);
    	getContentPane().add(lblNewLabel_1_1);
    	
    	JButton btnNewButton = new JButton("取消");
    	btnNewButton.setBounds(390, 149, 91, 27);
    	getContentPane().add(btnNewButton);

        pack();
        setSize(515, 240); // 设置窗口大小
        setBounds(700, 400, 515, 240);
        
        btnNewButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				 System.exit(0);
				 //frame.dispose();
			}
		});
    }

    public void updateProgress(int progress) {
        progressBar.setValue(progress);
        
    }
    
//    public static void main(String[] args) {
//    	UploadProgressWindow window = new UploadProgressWindow("hua","hua",0.00);
//    	window.setVisible(true);
//	}
}
